streamlit-nightly 1.44.2.dev20250426__py3-none-any.whl → 1.44.2.dev20250428__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit/auth_util.py +1 -1
- streamlit/components/v1/custom_component.py +1 -1
- streamlit/config.py +16 -2
- streamlit/delta_generator.py +0 -3
- streamlit/deprecation_util.py +1 -1
- streamlit/elements/arrow.py +1 -1
- streamlit/elements/code.py +15 -0
- streamlit/elements/deck_gl_json_chart.py +1 -1
- streamlit/elements/doc_string.py +18 -26
- streamlit/elements/lib/built_in_chart_utils.py +8 -8
- streamlit/elements/lib/column_config_utils.py +1 -1
- streamlit/elements/lib/column_types.py +3 -0
- streamlit/elements/lib/image_utils.py +7 -7
- streamlit/elements/lib/pandas_styler_utils.py +7 -7
- streamlit/elements/map.py +1 -1
- streamlit/elements/plotly_chart.py +1 -1
- streamlit/elements/vega_charts.py +7 -7
- streamlit/elements/widgets/audio_input.py +1 -1
- streamlit/elements/widgets/button.py +1 -1
- streamlit/elements/widgets/button_group.py +5 -11
- streamlit/elements/widgets/camera_input.py +1 -1
- streamlit/elements/widgets/chat.py +1 -3
- streamlit/elements/widgets/checkbox.py +1 -1
- streamlit/elements/widgets/color_picker.py +1 -1
- streamlit/elements/widgets/data_editor.py +1 -1
- streamlit/elements/widgets/file_uploader.py +1 -3
- streamlit/elements/widgets/multiselect.py +1 -5
- streamlit/elements/widgets/number_input.py +1 -3
- streamlit/elements/widgets/radio.py +1 -5
- streamlit/elements/widgets/select_slider.py +3 -7
- streamlit/elements/widgets/selectbox.py +1 -5
- streamlit/elements/widgets/slider.py +1 -1
- streamlit/elements/widgets/text_widgets.py +2 -2
- streamlit/elements/widgets/time_widgets.py +2 -6
- streamlit/external/langchain/streamlit_callback_handler.py +4 -0
- streamlit/git_util.py +2 -2
- streamlit/hello/dataframe_demo.py +2 -2
- streamlit/navigation/page.py +1 -1
- streamlit/proto/Code_pb2.py +4 -3
- streamlit/proto/Code_pb2.pyi +9 -1
- streamlit/runtime/caching/cached_message_replay.py +1 -1
- streamlit/runtime/caching/legacy_cache_api.py +1 -1
- streamlit/runtime/caching/storage/dummy_cache_storage.py +1 -1
- streamlit/runtime/forward_msg_queue.py +8 -8
- streamlit/runtime/pages_manager.py +1 -3
- streamlit/runtime/scriptrunner/exec_code.py +1 -1
- streamlit/runtime/scriptrunner/magic.py +3 -4
- streamlit/runtime/scriptrunner/script_runner.py +2 -2
- streamlit/runtime/state/common.py +2 -2
- streamlit/runtime/state/session_state.py +2 -2
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.BGxEEkBO.js → ErrorOutline.esm.BXGjCB7E.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.BIvOCWXm.js → FileDownload.esm.sOCqSnDy.js} +1 -1
- streamlit/static/static/js/{FileHelper.CJg2rGQf.js → FileHelper.DuN7B5ko.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.BKO5MjJ1.js → FormClearHelper.mBqxy6fp.js} +1 -1
- streamlit/static/static/js/{Hooks.Ch4fyM-d.js → Hooks.B8RCaOU-.js} +1 -1
- streamlit/static/static/js/{InputInstructions.BVG0uTsn.js → InputInstructions.CgQJAdmY.js} +1 -1
- streamlit/static/static/js/{ProgressBar.qtOeZiGm.js → ProgressBar.o46iipVl.js} +1 -1
- streamlit/static/static/js/{RenderInPortalIfExists.BNrfjgR-.js → RenderInPortalIfExists.CZifGklq.js} +1 -1
- streamlit/static/static/js/{Toolbar.DLYoM1Wd.js → Toolbar.CKRoYZWM.js} +1 -1
- streamlit/static/static/js/{base-input.CMZL3Njp.js → base-input.Me5gYF5B.js} +1 -1
- streamlit/static/static/js/{checkbox.Bg2c6brb.js → checkbox.CWWogItI.js} +1 -1
- streamlit/static/static/js/{createSuper.feapqlxC.js → createSuper.Bsmy7vnu.js} +1 -1
- streamlit/static/static/js/{data-grid-overlay-editor.CPfW2LFj.js → data-grid-overlay-editor.CgAv1I8N.js} +1 -1
- streamlit/static/static/js/{downloader.DzXny7Ld.js → downloader.BbuyvUmM.js} +1 -1
- streamlit/static/static/js/{es6.0m8Dphx5.js → es6.cFKClVYr.js} +2 -2
- streamlit/static/static/js/{iframeResizer.contentWindow.cmKtyqx-.js → iframeResizer.contentWindow.D00awOKx.js} +1 -1
- streamlit/static/static/js/{index.BvuI_MOQ.js → index.B0eFd777.js} +1 -1
- streamlit/static/static/js/{index.CaUiwEHb.js → index.B5KSWyCG.js} +1 -1
- streamlit/static/static/js/{index.CPBpuLNa.js → index.B6NqnBxa.js} +1 -1
- streamlit/static/static/js/{index.cslPh4fD.js → index.BKz9YyeL.js} +1 -1
- streamlit/static/static/js/{index.Cz5dPfTR.js → index.BMizE8Sq.js} +1 -1
- streamlit/static/static/js/{index.qG6NX4j3.js → index.BY-1pChC.js} +1 -1
- streamlit/static/static/js/{index.lC8LhcmX.js → index.B_FepcMP.js} +1 -1
- streamlit/static/static/js/{index.l2ZjmqZa.js → index.BfEtVe_N.js} +1 -1
- streamlit/static/static/js/{index.C4ApZ9VX.js → index.Bo5OoJ1E.js} +1 -1
- streamlit/static/static/js/{index.GK7AGRO0.js → index.BtCmnwwO.js} +1 -1
- streamlit/static/static/js/{index.C-FM6HWK.js → index.BtTvTjVr.js} +5 -5
- streamlit/static/static/js/{index.BOLpjodc.js → index.By8gv4Ay.js} +1 -1
- streamlit/static/static/js/{index.lmhSYtGE.js → index.C8S8FJep.js} +1 -1
- streamlit/static/static/js/{index.9ahYhn9L.js → index.CC6pozcl.js} +1 -1
- streamlit/static/static/js/{index.CoEs3Tyr.js → index.CEFfPwWA.js} +1 -1
- streamlit/static/static/js/{index.C9SZjgyE.js → index.CSZNuohX.js} +1 -1
- streamlit/static/static/js/{index.B1SRlRQI.js → index.CZT8t1KG.js} +1 -1
- streamlit/static/static/js/{index.CrKlAaBP.js → index.Cg3APxPS.js} +1 -1
- streamlit/static/static/js/{index.Cz-wSZKK.js → index.CtsvxUli.js} +1 -1
- streamlit/static/static/js/{index.Bml5MH48.js → index.D67skAdZ.js} +1 -1
- streamlit/static/static/js/{index.C51U-ytW.js → index.DUVjoXrp.js} +1 -1
- streamlit/static/static/js/{index.DYNcgXHh.js → index.DZSznc3f.js} +1 -1
- streamlit/static/static/js/{index.DZEEja3T.js → index.Db4G4s87.js} +1 -1
- streamlit/static/static/js/{index.BkUl8Uwz.js → index.DkQYsEGq.js} +39 -39
- streamlit/static/static/js/{index.CaDlXCxB.js → index.Dn4hsDID.js} +1 -1
- streamlit/static/static/js/{index.D75DmXmJ.js → index.DnnK1XX4.js} +1 -1
- streamlit/static/static/js/{index.Dc-nqnmm.js → index.GIpP3S4h.js} +1 -1
- streamlit/static/static/js/{index.NE3kJsno.js → index.HOc29Qsj.js} +1 -1
- streamlit/static/static/js/{index.DFJR7tFk.js → index.VrX7AJMW.js} +1 -1
- streamlit/static/static/js/{index.CeVeyA9j.js → index.ZMXLPc9m.js} +1 -1
- streamlit/static/static/js/{index.DXwLRPNi.js → index.Zbagu1xh.js} +1 -1
- streamlit/static/static/js/{index.BQdNrQcI.js → index.bliAXvPp.js} +1 -1
- streamlit/static/static/js/{index.Dj9pydGj.js → index.djYQBt-8.js} +1 -1
- streamlit/static/static/js/{index.45HlJMvy.js → index.eVt4urZS.js} +1 -1
- streamlit/static/static/js/{index.Br4Vls5z.js → index.ew1fqjzv.js} +1 -1
- streamlit/static/static/js/{index.T6zTT7so.js → index.v9S4U7E0.js} +1 -1
- streamlit/static/static/js/index.xsH4HHeE.js +6 -0
- streamlit/static/static/js/{index.8zBbwiSq.js → index.zbOUPreQ.js} +1 -1
- streamlit/static/static/js/{input.AzemsQR7.js → input.E-TEQSd2.js} +1 -1
- streamlit/static/static/js/{memory.BNnDm5qx.js → memory.C47SiSLX.js} +1 -1
- streamlit/static/static/js/{mergeWith.CnAe-pY8.js → mergeWith.CuOPq9Xx.js} +1 -1
- streamlit/static/static/js/{number-overlay-editor.CoO3Xzpl.js → number-overlay-editor.oJywx_AR.js} +1 -1
- streamlit/static/static/js/{possibleConstructorReturn.-4k2karl.js → possibleConstructorReturn.DezSYWQP.js} +1 -1
- streamlit/static/static/js/{sandbox.B_lhrPSt.js → sandbox.CpLGEYsx.js} +1 -1
- streamlit/static/static/js/{textarea.BXroYkeL.js → textarea.CF2OGnSF.js} +1 -1
- streamlit/static/static/js/{timepicker.mhMg0du0.js → timepicker.CckJhoGD.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.xDE9XBoI.js → toConsumableArray.DrtLgJ_5.js} +1 -1
- streamlit/static/static/js/{uniqueId.DPZFapqq.js → uniqueId.kgGoKER7.js} +1 -1
- streamlit/static/static/js/{useBasicWidgetState.DWXpUITX.js → useBasicWidgetState.CHBqT0_O.js} +1 -1
- streamlit/static/static/js/{useOnInputChange.FMGxl8Ty.js → useOnInputChange.A8V2n4e2.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.cCJx5Did.js → withFullScreenWrapper.Bh5OZGIu.js} +1 -1
- streamlit/type_util.py +2 -2
- streamlit/watcher/event_based_path_watcher.py +14 -0
- streamlit/watcher/local_sources_watcher.py +43 -7
- streamlit/web/bootstrap.py +3 -3
- streamlit/web/cli.py +4 -4
- streamlit/web/server/media_file_handler.py +2 -2
- {streamlit_nightly-1.44.2.dev20250426.dist-info → streamlit_nightly-1.44.2.dev20250428.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.44.2.dev20250426.dist-info → streamlit_nightly-1.44.2.dev20250428.dist-info}/RECORD +130 -130
- {streamlit_nightly-1.44.2.dev20250426.dist-info → streamlit_nightly-1.44.2.dev20250428.dist-info}/WHEEL +1 -1
- streamlit/static/static/js/index.t--hEgTQ.js +0 -6
- {streamlit_nightly-1.44.2.dev20250426.data → streamlit_nightly-1.44.2.dev20250428.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.44.2.dev20250426.dist-info → streamlit_nightly-1.44.2.dev20250428.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.44.2.dev20250426.dist-info → streamlit_nightly-1.44.2.dev20250428.dist-info}/top_level.txt +0 -0
streamlit/auth_util.py
CHANGED
@@ -40,7 +40,7 @@ class AuthCache:
|
|
40
40
|
|
41
41
|
# for set method, we are follow the same signature used in Authlib
|
42
42
|
# the expires_in is not used in our case
|
43
|
-
def set(self, key, value, expires_in):
|
43
|
+
def set(self, key, value, expires_in): # noqa: ARG002
|
44
44
|
self.cache[key] = value
|
45
45
|
|
46
46
|
def get_dict(self):
|
@@ -210,7 +210,7 @@ And if you're using Streamlit Cloud, add "pyarrow" to your requirements.txt."""
|
|
210
210
|
)
|
211
211
|
element.component_instance.id = computed_id
|
212
212
|
|
213
|
-
def deserialize_component(ui_value
|
213
|
+
def deserialize_component(ui_value):
|
214
214
|
# ui_value is an object from json, an ArrowTable proto, or a bytearray
|
215
215
|
return ui_value
|
216
216
|
|
streamlit/config.py
CHANGED
@@ -662,6 +662,20 @@ _create_option(
|
|
662
662
|
|
663
663
|
_create_section("server", "Settings for the Streamlit server")
|
664
664
|
|
665
|
+
|
666
|
+
_create_option(
|
667
|
+
"server.folderWatchList",
|
668
|
+
description="""
|
669
|
+
List of folders to watch for changes.
|
670
|
+
|
671
|
+
By default, Streamlit watches for files in the current working directory.
|
672
|
+
Use this parameter to specify additional folders to watch.
|
673
|
+
|
674
|
+
Note: This is a list of absolute paths.
|
675
|
+
""",
|
676
|
+
default_val=[],
|
677
|
+
)
|
678
|
+
|
665
679
|
_create_option(
|
666
680
|
"server.folderWatchBlacklist",
|
667
681
|
description="""
|
@@ -1561,8 +1575,8 @@ def _check_conflicts() -> None:
|
|
1561
1575
|
|
1562
1576
|
# When using the Node server, we must always connect to 8501 (this is
|
1563
1577
|
# hard-coded in JS). Otherwise, the browser would decide what port to
|
1564
|
-
# connect to based on window.location.port, which in dev is going
|
1565
|
-
# be (3000)
|
1578
|
+
# connect to based on window.location.port, which in dev is going
|
1579
|
+
# to be (3000)
|
1566
1580
|
|
1567
1581
|
# Import logger locally to prevent circular references
|
1568
1582
|
from streamlit.logger import get_logger
|
streamlit/delta_generator.py
CHANGED
@@ -423,7 +423,6 @@ class DeltaGenerator(
|
|
423
423
|
delta_type: str,
|
424
424
|
element_proto: Message,
|
425
425
|
add_rows_metadata: AddRowsMetadata | None = None,
|
426
|
-
user_key: str | None = None,
|
427
426
|
) -> DeltaGenerator:
|
428
427
|
"""Create NewElement delta, fill it, and enqueue it.
|
429
428
|
|
@@ -435,8 +434,6 @@ class DeltaGenerator(
|
|
435
434
|
The actual proto in the NewElement type e.g. Alert/Button/Slider
|
436
435
|
add_rows_metadata : AddRowsMetadata or None
|
437
436
|
Metadata for the add_rows method
|
438
|
-
user_key : str or None
|
439
|
-
A custom key for the element provided by the user.
|
440
437
|
|
441
438
|
Returns
|
442
439
|
-------
|
streamlit/deprecation_util.py
CHANGED
@@ -200,7 +200,7 @@ def _create_deprecated_obj_wrapper(obj: TObj, show_warning: Callable[[], Any]) -
|
|
200
200
|
|
201
201
|
@staticmethod
|
202
202
|
def _make_magic_function_proxy(name):
|
203
|
-
def proxy(self, *args):
|
203
|
+
def proxy(self, *args): # noqa: ARG001
|
204
204
|
maybe_show_warning()
|
205
205
|
return getattr(obj, name)
|
206
206
|
|
streamlit/elements/arrow.py
CHANGED
@@ -160,7 +160,7 @@ class DataframeState(TypedDict, total=False):
|
|
160
160
|
class DataframeSelectionSerde:
|
161
161
|
"""DataframeSelectionSerde is used to serialize and deserialize the dataframe selection state."""
|
162
162
|
|
163
|
-
def deserialize(self, ui_value: str | None
|
163
|
+
def deserialize(self, ui_value: str | None) -> DataframeState:
|
164
164
|
empty_selection_state: DataframeState = {
|
165
165
|
"selection": {
|
166
166
|
"rows": [],
|
streamlit/elements/code.py
CHANGED
@@ -16,6 +16,7 @@ from __future__ import annotations
|
|
16
16
|
|
17
17
|
from typing import TYPE_CHECKING, cast
|
18
18
|
|
19
|
+
from streamlit.elements.lib.layout_utils import WidthWithoutContent, validate_width
|
19
20
|
from streamlit.proto.Code_pb2 import Code as CodeProto
|
20
21
|
from streamlit.runtime.metrics_util import gather_metrics
|
21
22
|
from streamlit.string_util import clean_text
|
@@ -35,6 +36,7 @@ class CodeMixin:
|
|
35
36
|
line_numbers: bool = False,
|
36
37
|
wrap_lines: bool = False,
|
37
38
|
height: int | None = None,
|
39
|
+
width: WidthWithoutContent = "stretch",
|
38
40
|
) -> DeltaGenerator:
|
39
41
|
"""Display a code block with optional syntax highlighting.
|
40
42
|
|
@@ -67,6 +69,11 @@ class CodeMixin:
|
|
67
69
|
its content. Vertical scrolling within the element is enabled when
|
68
70
|
the height does not accomodate all lines.
|
69
71
|
|
72
|
+
width : "stretch" or int
|
73
|
+
The width of the code block. This can be either:
|
74
|
+
- "stretch" (default): The code block will stretch to fill the container width
|
75
|
+
- An integer: The code block will have a fixed width in pixels
|
76
|
+
|
70
77
|
Examples
|
71
78
|
--------
|
72
79
|
>>> import streamlit as st
|
@@ -106,6 +113,14 @@ class CodeMixin:
|
|
106
113
|
code_proto.wrap_lines = wrap_lines
|
107
114
|
if height:
|
108
115
|
code_proto.height = height
|
116
|
+
|
117
|
+
# Set width configuration
|
118
|
+
validate_width(width)
|
119
|
+
if isinstance(width, int):
|
120
|
+
code_proto.width_config.pixel_width = width
|
121
|
+
else:
|
122
|
+
code_proto.width_config.use_stretch = True
|
123
|
+
|
109
124
|
return self.dg._enqueue("code", code_proto)
|
110
125
|
|
111
126
|
@property
|
@@ -233,7 +233,7 @@ class PydeckState(TypedDict, total=False):
|
|
233
233
|
class PydeckSelectionSerde:
|
234
234
|
"""PydeckSelectionSerde is used to serialize and deserialize the Pydeck selection state."""
|
235
235
|
|
236
|
-
def deserialize(self, ui_value: str | None
|
236
|
+
def deserialize(self, ui_value: str | None) -> PydeckState:
|
237
237
|
empty_selection_state: PydeckState = {
|
238
238
|
"selection": {
|
239
239
|
"indices": {},
|
streamlit/elements/doc_string.py
CHANGED
@@ -28,7 +28,7 @@ from streamlit.proto.DocString_pb2 import DocString as DocStringProto
|
|
28
28
|
from streamlit.proto.DocString_pb2 import Member as MemberProto
|
29
29
|
from streamlit.runtime.metrics_util import gather_metrics
|
30
30
|
from streamlit.runtime.scriptrunner.script_runner import (
|
31
|
-
__file__ as SCRIPTRUNNER_FILENAME,
|
31
|
+
__file__ as SCRIPTRUNNER_FILENAME, # noqa: N812
|
32
32
|
)
|
33
33
|
from streamlit.runtime.secrets import Secrets
|
34
34
|
from streamlit.string_util import is_mem_address_str
|
@@ -149,18 +149,14 @@ def _marshall(doc_string_proto: DocStringProto, obj: Any) -> None:
|
|
149
149
|
|
150
150
|
def _get_name(obj):
|
151
151
|
# Try to get the fully-qualified name of the object.
|
152
|
-
# For example:
|
153
|
-
#
|
154
|
-
#
|
155
|
-
# The name is bar.Baz
|
152
|
+
# For example: st.help(bar.Baz(123))
|
153
|
+
# The name is bar.Baz
|
156
154
|
name = getattr(obj, "__qualname__", None)
|
157
155
|
if name:
|
158
156
|
return name
|
159
157
|
|
160
158
|
# Try to get the name of the object.
|
161
|
-
# For example:
|
162
|
-
# st.help(bar.Baz(123))
|
163
|
-
#
|
159
|
+
# For example: st.help(bar.Baz(123))
|
164
160
|
# The name is Baz
|
165
161
|
return getattr(obj, "__name__", None)
|
166
162
|
|
@@ -175,10 +171,6 @@ def _get_signature(obj):
|
|
175
171
|
|
176
172
|
sig = ""
|
177
173
|
|
178
|
-
# TODO: Can we replace below with this?
|
179
|
-
# with contextlib.suppress(ValueError):
|
180
|
-
# sig = str(inspect.signature(obj))
|
181
|
-
|
182
174
|
try:
|
183
175
|
sig = str(inspect.signature(obj))
|
184
176
|
except ValueError:
|
@@ -248,20 +240,20 @@ def _get_variable_name_from_code_str(code):
|
|
248
240
|
|
249
241
|
# Example:
|
250
242
|
#
|
251
|
-
# tree = Module(
|
252
|
-
# body=[
|
253
|
-
# Expr(
|
254
|
-
# value=Call(
|
255
|
-
# args=[
|
256
|
-
# Name(id='the variable name')
|
257
|
-
# ],
|
258
|
-
# keywords=[
|
259
|
-
# ???
|
260
|
-
# ],
|
261
|
-
# )
|
262
|
-
# )
|
263
|
-
# ]
|
264
|
-
# )
|
243
|
+
# > tree = Module(
|
244
|
+
# > body=[
|
245
|
+
# > Expr(
|
246
|
+
# > value=Call(
|
247
|
+
# > args=[
|
248
|
+
# > Name(id='the variable name')
|
249
|
+
# > ],
|
250
|
+
# > keywords=[
|
251
|
+
# > ???
|
252
|
+
# > ],
|
253
|
+
# > )
|
254
|
+
# > )
|
255
|
+
# > ]
|
256
|
+
# > )
|
265
257
|
|
266
258
|
# Check if this is an magic call (i.e. it's not st.help or st.write).
|
267
259
|
# If that's the case, just clean it up and return it.
|
@@ -366,8 +366,8 @@ def _infer_vegalite_type(
|
|
366
366
|
return "quantitative"
|
367
367
|
|
368
368
|
elif typ == "categorical" and data.cat.ordered:
|
369
|
-
#
|
370
|
-
# return ("ordinal", data.cat.categories.tolist())
|
369
|
+
# The original code returns a tuple here:
|
370
|
+
# return ("ordinal", data.cat.categories.tolist()) # noqa: ERA001
|
371
371
|
# But returning the tuple here isn't compatible with our
|
372
372
|
# built-in chart implementation. And it also doesn't seem to be necessary.
|
373
373
|
# Altair already extracts the correct sort order somewhere else.
|
@@ -387,11 +387,11 @@ def _infer_vegalite_type(
|
|
387
387
|
return "temporal"
|
388
388
|
else:
|
389
389
|
# STREAMLIT MOD: I commented this out since Streamlit doesn't use warnings.warn.
|
390
|
-
# warnings.warn(
|
391
|
-
# "I don't know how to infer vegalite type from '{}'. "
|
392
|
-
# "Defaulting to nominal.".format(typ),
|
393
|
-
# stacklevel=1,
|
394
|
-
# )
|
390
|
+
# > warnings.warn(
|
391
|
+
# > "I don't know how to infer vegalite type from '{}'. "
|
392
|
+
# > "Defaulting to nominal.".format(typ),
|
393
|
+
# > stacklevel=1,
|
394
|
+
# > )
|
395
395
|
return "nominal"
|
396
396
|
|
397
397
|
|
@@ -551,7 +551,7 @@ def _melt_data(
|
|
551
551
|
)
|
552
552
|
|
553
553
|
# Arrow has problems with object types after melting two different dtypes
|
554
|
-
# pyarrow.lib.ArrowTypeError: "Expected a <TYPE> object, got a object"
|
554
|
+
# > pyarrow.lib.ArrowTypeError: "Expected a <TYPE> object, got a object"
|
555
555
|
fixed_df = dataframe_util.fix_arrow_incompatible_column_types(
|
556
556
|
melted_df,
|
557
557
|
selected_columns=[
|
@@ -188,7 +188,7 @@ def _determine_data_kind_via_arrow(field: pa.Field) -> ColumnDataKind:
|
|
188
188
|
|
189
189
|
# Interval does not seem to work correctly:
|
190
190
|
# if pa.types.is_interval(field_type):
|
191
|
-
# return ColumnDataKind.INTERVAL
|
191
|
+
# return ColumnDataKind.INTERVAL # noqa: ERA001
|
192
192
|
|
193
193
|
if pa.types.is_binary(field_type):
|
194
194
|
return ColumnDataKind.BYTES
|
@@ -122,7 +122,7 @@ def _validate_image_format_string(
|
|
122
122
|
return "JPEG"
|
123
123
|
|
124
124
|
|
125
|
-
def
|
125
|
+
def _pil_to_bytes(
|
126
126
|
image: PILImage,
|
127
127
|
format: ImageFormat = "JPEG",
|
128
128
|
quality: int = 100,
|
@@ -139,7 +139,7 @@ def _PIL_to_bytes(
|
|
139
139
|
return tmp.getvalue()
|
140
140
|
|
141
141
|
|
142
|
-
def
|
142
|
+
def _bytesio_to_bytes(data: io.BytesIO) -> bytes:
|
143
143
|
data.seek(0)
|
144
144
|
return data.getvalue()
|
145
145
|
|
@@ -151,7 +151,7 @@ def _np_array_to_bytes(array: npt.NDArray[Any], output_format: str = "JPEG") ->
|
|
151
151
|
img = Image.fromarray(array.astype(np.uint8))
|
152
152
|
format = _validate_image_format_string(img, output_format)
|
153
153
|
|
154
|
-
return
|
154
|
+
return _pil_to_bytes(img, format)
|
155
155
|
|
156
156
|
|
157
157
|
def _verify_np_shape(array: npt.NDArray[Any]) -> npt.NDArray[Any]:
|
@@ -199,11 +199,11 @@ def _ensure_image_size_and_format(
|
|
199
199
|
# versions. The types don't seem to reflect this, though, hence the type: ignore
|
200
200
|
# below.
|
201
201
|
pil_image = pil_image.resize((width, new_height), resample=Image.BILINEAR) # type: ignore[attr-defined]
|
202
|
-
return
|
202
|
+
return _pil_to_bytes(pil_image, format=image_format, quality=90)
|
203
203
|
|
204
204
|
if pil_image.format != image_format:
|
205
205
|
# We need to reformat the image.
|
206
|
-
return
|
206
|
+
return _pil_to_bytes(pil_image, format=image_format, quality=90)
|
207
207
|
|
208
208
|
# No resizing or reformatting necessary - return the original bytes.
|
209
209
|
return image_data
|
@@ -302,13 +302,13 @@ def image_to_url(
|
|
302
302
|
# PIL Images
|
303
303
|
elif isinstance(image, (ImageFile.ImageFile, Image.Image)):
|
304
304
|
format = _validate_image_format_string(image, output_format)
|
305
|
-
image_data =
|
305
|
+
image_data = _pil_to_bytes(image, format)
|
306
306
|
|
307
307
|
# BytesIO
|
308
308
|
# Note: This doesn't support SVG. We could convert to png (cairosvg.svg2png)
|
309
309
|
# or just decode BytesIO to string and handle that way.
|
310
310
|
elif isinstance(image, io.BytesIO):
|
311
|
-
image_data =
|
311
|
+
image_data = _bytesio_to_bytes(image)
|
312
312
|
|
313
313
|
# Numpy Arrays (ie opencv)
|
314
314
|
elif isinstance(image, np.ndarray):
|
@@ -196,13 +196,13 @@ def _pandas_style_to_css(
|
|
196
196
|
|
197
197
|
# In pandas >= 1.1.0
|
198
198
|
# translated_style["cellstyle"] has the following shape:
|
199
|
-
# [
|
200
|
-
# {
|
201
|
-
# "props": [("color", " black"), ("background-color", "orange"), ("", "")],
|
202
|
-
# "selectors": ["row0_col0"]
|
203
|
-
# }
|
204
|
-
# ...
|
205
|
-
# ]
|
199
|
+
# > [
|
200
|
+
# > {
|
201
|
+
# > "props": [("color", " black"), ("background-color", "orange"), ("", "")],
|
202
|
+
# > "selectors": ["row0_col0"]
|
203
|
+
# > }
|
204
|
+
# > ...
|
205
|
+
# > ]
|
206
206
|
if style_type == "table_styles":
|
207
207
|
cell_selectors = [style["selector"]]
|
208
208
|
else:
|
streamlit/elements/map.py
CHANGED
@@ -230,7 +230,7 @@ class MapMixin:
|
|
230
230
|
#
|
231
231
|
# For reference, this was the docstring for map_style:
|
232
232
|
#
|
233
|
-
# map_style : str
|
233
|
+
# map_style : str, None
|
234
234
|
# One of Mapbox's map style URLs. A full list can be found here:
|
235
235
|
# https://docs.mapbox.com/api/maps/styles/#mapbox-styles
|
236
236
|
#
|
@@ -214,7 +214,7 @@ class PlotlyChartSelectionSerde:
|
|
214
214
|
selection state.
|
215
215
|
"""
|
216
216
|
|
217
|
-
def deserialize(self, ui_value: str | None
|
217
|
+
def deserialize(self, ui_value: str | None) -> PlotlyState:
|
218
218
|
empty_selection_state: PlotlyState = {
|
219
219
|
"selection": {
|
220
220
|
"points": [],
|
@@ -227,7 +227,7 @@ class VegaLiteStateSerde:
|
|
227
227
|
|
228
228
|
selection_parameters: Sequence[str]
|
229
229
|
|
230
|
-
def deserialize(self, ui_value: str | None
|
230
|
+
def deserialize(self, ui_value: str | None) -> VegaLiteState:
|
231
231
|
empty_selection_state: VegaLiteState = {
|
232
232
|
"selection": AttributeDictionary(
|
233
233
|
# Initialize the select state with empty dictionaries for each selection parameter.
|
@@ -256,8 +256,8 @@ def _prepare_vega_lite_spec(
|
|
256
256
|
**kwargs,
|
257
257
|
) -> VegaLiteSpec:
|
258
258
|
if kwargs:
|
259
|
-
# Support passing in kwargs.
|
260
|
-
#
|
259
|
+
# Support passing in kwargs.
|
260
|
+
# > marshall(proto, {foo: 'bar'}, baz='boz')
|
261
261
|
# Merge spec with unflattened kwargs, where kwargs take precedence.
|
262
262
|
# This only works for string keys, but kwarg keys are strings anyways.
|
263
263
|
spec = dict(spec, **dicttools.unflatten(kwargs, _CHANNELS))
|
@@ -313,10 +313,10 @@ def _marshall_chart_data(
|
|
313
313
|
del spec["datasets"]
|
314
314
|
|
315
315
|
# Pull data out of spec dict when it's in a top-level 'data' key:
|
316
|
-
#
|
317
|
-
#
|
318
|
-
#
|
319
|
-
#
|
316
|
+
# > {data: df}
|
317
|
+
# > {data: {values: df, ...}}
|
318
|
+
# > {data: {url: 'url'}}
|
319
|
+
# > {data: {name: 'foo'}}
|
320
320
|
if "data" in spec:
|
321
321
|
data_spec = spec["data"]
|
322
322
|
|
@@ -73,7 +73,7 @@ class AudioInputSerde:
|
|
73
73
|
return state_proto
|
74
74
|
|
75
75
|
def deserialize(
|
76
|
-
self, ui_value: FileUploaderStateProto | None
|
76
|
+
self, ui_value: FileUploaderStateProto | None
|
77
77
|
) -> SomeUploadedAudioFile:
|
78
78
|
upload_files = _get_upload_files(ui_value)
|
79
79
|
if len(upload_files) == 0:
|
@@ -107,11 +107,7 @@ class _MultiSelectSerde(Generic[T]):
|
|
107
107
|
indices = check_and_convert_to_indices(self.options, value)
|
108
108
|
return indices if indices is not None else []
|
109
109
|
|
110
|
-
def deserialize(
|
111
|
-
self,
|
112
|
-
ui_value: list[int] | None,
|
113
|
-
widget_id: str = "",
|
114
|
-
) -> list[T]:
|
110
|
+
def deserialize(self, ui_value: list[int] | None) -> list[T]:
|
115
111
|
current_value: list[int] = (
|
116
112
|
ui_value if ui_value is not None else self.default_value
|
117
113
|
)
|
@@ -145,8 +141,8 @@ class _SingleSelectSerde(Generic[T]):
|
|
145
141
|
_value = [value] if value is not None else []
|
146
142
|
return self.multiselect_serde.serialize(_value)
|
147
143
|
|
148
|
-
def deserialize(self, ui_value: list[int] | None
|
149
|
-
deserialized = self.multiselect_serde.deserialize(ui_value
|
144
|
+
def deserialize(self, ui_value: list[int] | None) -> T | None:
|
145
|
+
deserialized = self.multiselect_serde.deserialize(ui_value)
|
150
146
|
|
151
147
|
if len(deserialized) == 0:
|
152
148
|
return None
|
@@ -182,10 +178,8 @@ class ButtonGroupSerde(Generic[T]):
|
|
182
178
|
def serialize(self, value: T | list[T] | None) -> list[int]:
|
183
179
|
return self.serde.serialize(cast("Any", value))
|
184
180
|
|
185
|
-
def deserialize(
|
186
|
-
self
|
187
|
-
) -> list[T] | T | None:
|
188
|
-
return self.serde.deserialize(ui_value, widget_id)
|
181
|
+
def deserialize(self, ui_value: list[int] | None) -> list[T] | T | None:
|
182
|
+
return self.serde.deserialize(ui_value)
|
189
183
|
|
190
184
|
|
191
185
|
def get_mapped_options(
|
@@ -73,7 +73,7 @@ class CameraInputSerde:
|
|
73
73
|
return state_proto
|
74
74
|
|
75
75
|
def deserialize(
|
76
|
-
self, ui_value: FileUploaderStateProto | None
|
76
|
+
self, ui_value: FileUploaderStateProto | None
|
77
77
|
) -> SomeUploadedSnapshotFile:
|
78
78
|
upload_files = _get_upload_files(ui_value)
|
79
79
|
if len(upload_files) == 0:
|
@@ -196,9 +196,7 @@ class ChatInputSerde:
|
|
196
196
|
allowed_types: Sequence[str] | None = None
|
197
197
|
|
198
198
|
def deserialize(
|
199
|
-
self,
|
200
|
-
ui_value: ChatInputValueProto | None,
|
201
|
-
widget_id: str = "",
|
199
|
+
self, ui_value: ChatInputValueProto | None
|
202
200
|
) -> str | ChatInputValue | None:
|
203
201
|
if ui_value is None or not ui_value.HasField("data"):
|
204
202
|
return None
|
@@ -51,7 +51,7 @@ class CheckboxSerde:
|
|
51
51
|
def serialize(self, v: bool) -> bool:
|
52
52
|
return bool(v)
|
53
53
|
|
54
|
-
def deserialize(self, ui_value: bool | None
|
54
|
+
def deserialize(self, ui_value: bool | None) -> bool:
|
55
55
|
return bool(ui_value if ui_value is not None else self.value)
|
56
56
|
|
57
57
|
|
@@ -53,7 +53,7 @@ class ColorPickerSerde:
|
|
53
53
|
def serialize(self, v: str) -> str:
|
54
54
|
return str(v)
|
55
55
|
|
56
|
-
def deserialize(self, ui_value: str | None
|
56
|
+
def deserialize(self, ui_value: str | None) -> str:
|
57
57
|
return str(ui_value if ui_value is not None else self.value)
|
58
58
|
|
59
59
|
|
@@ -137,7 +137,7 @@ class EditingState(TypedDict, total=False):
|
|
137
137
|
class DataEditorSerde:
|
138
138
|
"""DataEditorSerde is used to serialize and deserialize the data editor state."""
|
139
139
|
|
140
|
-
def deserialize(self, ui_value: str | None
|
140
|
+
def deserialize(self, ui_value: str | None) -> EditingState:
|
141
141
|
data_editor_state: EditingState = (
|
142
142
|
{
|
143
143
|
"edited_rows": {},
|
@@ -102,9 +102,7 @@ class FileUploaderSerde:
|
|
102
102
|
accept_multiple_files: bool
|
103
103
|
allowed_types: Sequence[str] | None = None
|
104
104
|
|
105
|
-
def deserialize(
|
106
|
-
self, ui_value: FileUploaderStateProto | None, widget_id: str
|
107
|
-
) -> SomeUploadedFiles:
|
105
|
+
def deserialize(self, ui_value: FileUploaderStateProto | None) -> SomeUploadedFiles:
|
108
106
|
upload_files = _get_upload_files(ui_value)
|
109
107
|
|
110
108
|
for file in upload_files:
|
@@ -116,11 +116,7 @@ class MultiSelectSerde(Generic[T]):
|
|
116
116
|
values.append(cast("str", v))
|
117
117
|
return values
|
118
118
|
|
119
|
-
def deserialize(
|
120
|
-
self,
|
121
|
-
ui_value: list[str] | None,
|
122
|
-
widget_id: str = "",
|
123
|
-
) -> list[T | str] | list[T]:
|
119
|
+
def deserialize(self, ui_value: list[str] | None) -> list[T | str] | list[T]:
|
124
120
|
if ui_value is None:
|
125
121
|
return [self.options[i] for i in self.default_options_indices]
|
126
122
|
|
@@ -70,9 +70,7 @@ class NumberInputSerde:
|
|
70
70
|
def serialize(self, v: Number | None) -> Number | None:
|
71
71
|
return v
|
72
72
|
|
73
|
-
def deserialize(
|
74
|
-
self, ui_value: Number | None, widget_id: str = ""
|
75
|
-
) -> Number | None:
|
73
|
+
def deserialize(self, ui_value: Number | None) -> Number | None:
|
76
74
|
val: Number | None = ui_value if ui_value is not None else self.value
|
77
75
|
|
78
76
|
if val is not None and self.data_type == NumberInputProto.INT:
|
@@ -66,11 +66,7 @@ class RadioSerde(Generic[T]):
|
|
66
66
|
|
67
67
|
return 0 if len(self.options) == 0 else index_(self.options, v)
|
68
68
|
|
69
|
-
def deserialize(
|
70
|
-
self,
|
71
|
-
ui_value: int | None,
|
72
|
-
widget_id: str = "",
|
73
|
-
) -> T | None:
|
69
|
+
def deserialize(self, ui_value: int | None) -> T | None:
|
74
70
|
idx = ui_value if ui_value is not None else self.index
|
75
71
|
|
76
72
|
return (
|
@@ -78,11 +78,7 @@ class SelectSliderSerde(Generic[T]):
|
|
78
78
|
def serialize(self, v: object) -> list[int]:
|
79
79
|
return self._as_index_list(v)
|
80
80
|
|
81
|
-
def deserialize(
|
82
|
-
self,
|
83
|
-
ui_value: list[int] | None,
|
84
|
-
widget_id: str = "",
|
85
|
-
) -> T | tuple[T, T]:
|
81
|
+
def deserialize(self, ui_value: list[int] | None) -> T | tuple[T, T]:
|
86
82
|
if not ui_value:
|
87
83
|
# Widget has not been used; fallback to the original value,
|
88
84
|
ui_value = self.value
|
@@ -128,8 +124,8 @@ class SelectSliderMixin:
|
|
128
124
|
# The overload-overlap error given by mypy here stems from
|
129
125
|
# the fact that
|
130
126
|
#
|
131
|
-
#
|
132
|
-
#
|
127
|
+
# > opt:List[object] = [1, 2, "3"]
|
128
|
+
# > select_slider("foo", options=opt, value=[1, 2])
|
133
129
|
#
|
134
130
|
# matches both overloads; "opt" matches
|
135
131
|
# OptionsSequence[T] in each case, binding T to object.
|
@@ -115,11 +115,7 @@ class SelectboxSerde(Generic[T]):
|
|
115
115
|
# options
|
116
116
|
return cast("str", v)
|
117
117
|
|
118
|
-
def deserialize(
|
119
|
-
self,
|
120
|
-
ui_value: str | None,
|
121
|
-
widget_id: str = "",
|
122
|
-
) -> T | str | None:
|
118
|
+
def deserialize(self, ui_value: str | None) -> T | str | None:
|
123
119
|
# check if the option is pointing to a generic option type T,
|
124
120
|
# otherwise return the option itself
|
125
121
|
if ui_value is None:
|
@@ -54,7 +54,7 @@ if TYPE_CHECKING:
|
|
54
54
|
class TextInputSerde:
|
55
55
|
value: str | None
|
56
56
|
|
57
|
-
def deserialize(self, ui_value: str | None
|
57
|
+
def deserialize(self, ui_value: str | None) -> str | None:
|
58
58
|
return ui_value if ui_value is not None else self.value
|
59
59
|
|
60
60
|
def serialize(self, v: str | None) -> str | None:
|
@@ -65,7 +65,7 @@ class TextInputSerde:
|
|
65
65
|
class TextAreaSerde:
|
66
66
|
value: str | None
|
67
67
|
|
68
|
-
def deserialize(self, ui_value: str | None
|
68
|
+
def deserialize(self, ui_value: str | None) -> str | None:
|
69
69
|
return ui_value if ui_value is not None else self.value
|
70
70
|
|
71
71
|
def serialize(self, v: str | None) -> str | None:
|